home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1999 May: Tool Chest / Developer CD Series Tool Chest (Apple Computer)(May 1999).iso / Tool Chest / Development Kits / HyperCard Related / XCMDs & XFCNs / ProgressWindoid—C / ProgressWindoid.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-01-15  |  17.9 KB  |  602 lines  |  [TEXT/MPS ]

  1. /*
  2.  
  3.     © 1990 by Apple Computer, Inc.
  4.     Ken Doyle - C Translation of ProgressWindoid.p (written by Chris Thorman)
  5.     All Rights Reserved
  6.  
  7.     Permission granted for any kind of use as long as this notice is retained.
  8.     
  9.     Apple makes no claims as to the correctness or value of this software for
  10.     any purpose.  In fact, this software may well have bugs which will crash
  11.     your machine at crucial moments.
  12. */
  13.  
  14. /*
  15.     ProgressWindoid (WindowName, Loc, [Width, Text, Fraction, TextFont, TextSize])
  16.         
  17.     This HyperCard external window command creates a windoid that can be used
  18.     to show progress of a lengthy operation.
  19.     
  20.     The XFCN is called once and if successful, leaves an XWindoid which 
  21.     HyperCard will subsequently manage.  A successful call is indicated
  22.     by an empty return value from the XFCN.  If the return value is not
  23.     empty, then it should be interpreted as an error message.
  24.     
  25.     All interaction with the window takes place by getting and setting
  26.     its properties (see below), and through HyperCard’s open, close, show,
  27.     and hide commands.
  28.     
  29.     The WindowName argument is the name that the window will be given.  It
  30.     is required.  After creating the window, this name will be used from
  31.     HyperTalk to refer to it.
  32.  
  33.     The Loc argument is the point that will become the upper-left corner
  34.     of the windoid.  It is a two-item string in the form “20,50”.  It is 
  35.     a card-relative number, not screen relative.  It is required.
  36.     
  37.     The optional Width argument is total width of the windoid in pixels.  The 
  38.     minimum width is 140 pixels.  The maximum is 1200 pixels.  The default
  39.     is 250 pixels.
  40.     
  41.     The optional Text argument is the text that appears above the
  42.     progress bar in the windoid.  It may be empty.  It defaults to “Progress:”.
  43.     
  44.     The optional Fraction argument is the Fraction that the XWindoid
  45.     starts with when it is created.  It is a floating point number between
  46.     0.0 and 1.0.  It defaults to 0.0.
  47.     
  48.     The optional TextFont argument is the font that will be used for the text
  49.     in the windoid.  The name of the font (e.g. “Helvetica”) is used to specify
  50.     the font.  The default font is whatever font corresponds to 0 on the current
  51.     system (usually Geneva).
  52.     
  53.     The optional TextSize argument is the size of the text in the window.  It
  54.     is 12 by default.  The minimum size is 1 point and the maximum size is 127
  55.     points.
  56.     
  57.     All of the optional arguments correspond to HyperCard properties of the
  58.     windoid.  These are: the width, the text, the fraction, the textFont, and
  59.     the textSize.
  60.     
  61.     In addition to these special properties, the windoid also supports 
  62.     HyperCard’s standard window properties: the loc, the visible, and the
  63.     properties (which returns a list of the special properties of the windoid).
  64.     
  65. */
  66.  
  67. #include <Memory.h>
  68. #include <Fonts.h>
  69. #include <FixMath.h>
  70.  
  71. #include <HyperXCmd.h>
  72.  
  73. #define    kMinParams    2
  74. #define    kMaxParams    7
  75.  
  76. #define    kTextTopSpace    5
  77. #define    kTextBottomSpace    5
  78. #define    kTextLeftSideSpace    20
  79.  
  80. #define    kProgBarSideSpace    20
  81.  
  82. #define    kProgBarHeight        20
  83. #define    kProgBarBottomSpace    20
  84.  
  85. #define    kFract0    0
  86. #define    kFract1    0x40000000
  87.  
  88. /*    Since the extended type doesn't work well in Think C, the windowFraction field is a Fract 
  89.     rather than an extended (as in the Pascal example). Places in the code where the parameter 
  90.     is used are changed accordingly. In particular, FracMul is used to multiply windowFraction 
  91.     by the progress bar width and the Frac2X and X2Frac conversion routines are used when calling
  92.     the HyperCard ExtToStr and StrToExt routines.
  93. */
  94.  
  95. struct ProgressWindoidInfoRecord {
  96.     Str255        windowText;
  97.     Fract        windowFraction;
  98.     short        progBarTop;        /* Cached here, but could be determined from txSize */
  99.     short        progBarWidth;    /* Cached here, but could be determined from portRect */
  100. };
  101.  
  102. typedef struct ProgressWindoidInfoRecord ProgressWindoidInfoRecord;
  103. typedef ProgressWindoidInfoRecord *ProgressWindoidInfoPtr, **ProgressWindoidInfoHandle;
  104.  
  105.  
  106. #define ExitWithError(errorMsg)                     \
  107.     {                                                \
  108.     SetErrorResult(paramPtr, (StringPtr) errorMsg);    \
  109.     return;                                            \
  110.     }    
  111.  
  112. /* Prototypes */
  113. void SetErrorResult(XCmdPtr paramPtr, StringPtr errMsg);
  114. void LimitFractionValue(Fract *fraction);
  115. void LimitWidthValue(short *windWidth);
  116. void LimitTextSizeValue(short *textSize);
  117. void LimitTextSizeValue(short *textSize);
  118. void DoSetup(XCmdPtr paramPtr);
  119. void KillXWindow(XCmdPtr paramPtr, ProgressWindoidInfoHandle progWindInfo, WindowPtr theWindow);
  120. void DrawProgText(XCmdPtr paramPtr, ProgressWindoidInfoHandle progWindInfo, WindowPtr theWindow);
  121. void DrawProgBar(XCmdPtr paramPtr, ProgressWindoidInfoHandle progWindInfo, WindowPtr theWindow);
  122. void DoUpdate(XCmdPtr paramPtr, ProgressWindoidInfoHandle progWindInfo, WindowPtr theWindow);
  123. void DoMouseDown(XCmdPtr paramPtr, ProgressWindoidInfoHandle progWindInfo, 
  124.                     WindowPtr theWindow, EventRecord *theEvent);
  125. Handle GetProperty(XCmdPtr paramPtr, ProgressWindoidInfoHandle progWindInfo, 
  126.                     WindowPtr theWindow, StringPtr propName);
  127. void SetProperty(XCmdPtr paramPtr, ProgressWindoidInfoHandle progWindInfo, 
  128.                     WindowPtr theWindow, StringPtr propName, Handle propVal);
  129. void ProcessEvent(XCmdPtr paramPtr, XWEventInfoPtr myXWEventInfoPtr, 
  130.                         WindowPtr myWindow, EventRecord *myEvent);
  131. void DoEvent(XCmdPtr paramPtr);
  132.  
  133.  
  134. /* Main Entry Point */
  135. pascal void main(XCmdPtr paramPtr)
  136. {
  137.     if (paramPtr->paramCount == -1)
  138.         DoEvent(paramPtr);
  139.     else
  140.         DoSetup(paramPtr);            
  141. }
  142.  
  143. void SetErrorResult(XCmdPtr paramPtr, StringPtr errMsg)
  144. {
  145.     Str255    tempStr = "\p•••••••• Error: ";
  146.     short    len;
  147.     
  148.     len = tempStr[0];
  149.     BlockMove(&errMsg[1], &tempStr[len+1], errMsg[0]);
  150.     len += errMsg[0];
  151.     tempStr[0] = len;
  152.     paramPtr->returnValue = PasToZero(paramPtr, tempStr);
  153. }
  154.  
  155. void LimitFractionValue(Fract *fraction)
  156. {
  157.     if (*fraction < kFract0) *fraction = kFract0;
  158.     if (*fraction > kFract1) *fraction = kFract1;
  159. }
  160.  
  161. void LimitWidthValue(short *windWidth)
  162. {
  163.     if (*windWidth < 140) *windWidth = 140;
  164.     if (*windWidth > 1200) *windWidth = 1200;
  165. }
  166.  
  167. void LimitTextSizeValue(short *textSize)
  168. {
  169.     if (*textSize < 1) *textSize = 12;
  170.     if (*textSize > 127) *textSize = 12;
  171. }
  172.  
  173. #define kWindowName    0
  174. #define kLoc        kWindowName+1
  175. #define kWidth        kLoc+1
  176. #define kText        kWidth+1
  177. #define kFraction    kText+1
  178. #define kTextFont    kFraction+1
  179. #define kTextSize    kTextFont+1
  180.  
  181. void DoSetup(XCmdPtr paramPtr)
  182. {
  183.     Point        locParam;
  184.     short        widthParam;
  185.     Fract        fractionParam;
  186.     short        textFontParam;
  187.     short        textSizeParam;
  188.     
  189.     Rect        windowBounds;
  190.     WindowPtr    myWindowPtr;
  191.  
  192.     ProgressWindoidInfoHandle    progWindInfo;
  193.  
  194.     short        progBarTop;
  195.     short        progBarWidth;
  196.     short        windowHeight;
  197.     
  198.     Str255        windowNameParam;
  199.     Str255        tempStr;
  200.     Str255        paramStr;
  201.     Str255        textParam;
  202.  
  203.     /* PARSE PARAMETERS - Differs from Pascal version in that this
  204.        is not broken out as a separate routine.  This is done to avoid
  205.        having to declare all of the above locals as globals.  */
  206.        
  207.     if (paramPtr->paramCount < kMinParams) ExitWithError("\pToo few parameters");
  208.     if (paramPtr->paramCount > kMaxParams) ExitWithError("\pToo many parameters");
  209.  
  210.     /* Required Window Name Parameter */
  211.     
  212.     ZeroToPas(paramPtr, *(paramPtr->params[kWindowName]), windowNameParam);
  213.     if (windowNameParam[0] == 0) ExitWithError("\pEmpty window name was given");
  214.     
  215.     /* Required Location Parameter */
  216.     
  217.     ZeroToPas(paramPtr, *(paramPtr->params[kLoc]), paramStr);
  218.     StrToPoint(paramPtr, paramStr, &locParam);
  219.     
  220.     /*     locParam is passed in as card-relative, but we will need absolute coordinates. 
  221.         As it happens, LocalToGlobal accomplishes this, but the more correct
  222.         way would probably be to use EvalExpr(paramPtr, 'the loc of card window')
  223.         and add that loc to the loc that was passed in. */
  224.                   
  225.     LocalToGlobal(&locParam);
  226.  
  227.     /* Optional Width Parameter */
  228.     
  229.     if (paramPtr->paramCount >= kWidth)
  230.         {
  231.             ZeroToPas(paramPtr, *(paramPtr->params[kWidth]), paramStr);
  232.             widthParam = StrToNum(paramPtr, paramStr);
  233.             LimitWidthValue(&widthParam);
  234.         }
  235.     else 
  236.         {
  237.             widthParam = 250;
  238.         }
  239.         
  240.     /* Optional Text Parameter */
  241.     
  242.     if (paramPtr->paramCount >= kText)
  243.         {
  244.             ZeroToPas(paramPtr, *(paramPtr->params[kText]), textParam);
  245.         }
  246.     else 
  247.         {
  248.             BlockMove("\pProgress:", textParam, 10);
  249.         }
  250.     
  251.     /* Optional Fraction Parameter */
  252.     
  253.     if (paramPtr->paramCount >= kFraction)
  254.         {
  255.             ZeroToPas(paramPtr, *(paramPtr->params[kFraction]), paramStr);
  256.             if (paramStr[0] == 0)
  257.                 fractionParam = kFract0;
  258.             else
  259.                 {
  260.                 fractionParam = X2Frac(StrToExt(paramPtr, paramStr));
  261.                 }
  262.             LimitFractionValue(&fractionParam);
  263.         }
  264.     else 
  265.         {
  266.             fractionParam = kFract0;
  267.         }
  268.     
  269.     /* Optional TextFont Parameter */
  270.     
  271.     if (paramPtr->paramCount >= kTextFont)
  272.         {
  273.             ZeroToPas(paramPtr, *(paramPtr->params[kTextFont]), paramStr);
  274.             GetFNum(paramStr, &textFontParam);
  275.         }
  276.     else 
  277.         {
  278.             textFontParam = 0;
  279.         }
  280.         
  281.     /* Optional TextSize Parameter */
  282.  
  283.     if (paramPtr->paramCount >= kTextSize)
  284.         {
  285.             ZeroToPas(paramPtr, *(paramPtr->params[kTextSize]), paramStr);
  286.             textSizeParam = StrToNum(paramPtr, paramStr);
  287.             LimitTextSizeValue(&textSizeParam);
  288.         }
  289.     else 
  290.         {
  291.             textSizeParam = 12;
  292.         }
  293.         
  294.         
  295.     /* End of PARSE PARAMETERS section */
  296.         
  297.     progBarTop = kTextTopSpace + textSizeParam + kTextBottomSpace;
  298.     progBarWidth = widthParam - (2 * kProgBarSideSpace);
  299.  
  300.     windowHeight = progBarTop + kProgBarHeight + kProgBarBottomSpace;    
  301.     
  302.     windowBounds.left = locParam.h;
  303.     windowBounds.top = locParam.v;
  304.     windowBounds.right = locParam.h + widthParam;
  305.     windowBounds.bottom = locParam.v + windowHeight;
  306.         
  307.     progWindInfo = (ProgressWindoidInfoHandle) NewHandle(sizeof(ProgressWindoidInfoRecord));
  308.     if (progWindInfo == nil) ExitWithError("\pCouldn’t allocate storage for window variables");
  309.     
  310.     myWindowPtr = NewXWindow(paramPtr, &windowBounds, windowNameParam, false, 
  311.                                 palNoGrowProc, false, true);
  312.                                 
  313.     if (myWindowPtr == nil)
  314.         {
  315.             DisposHandle((Handle) progWindInfo);
  316.             ExitWithError("\pCouldn’t create XWindow");
  317.         }
  318.         
  319.     myWindowPtr->txFont = textFontParam;
  320.     myWindowPtr->txSize = textSizeParam;
  321.     
  322.     /*    All of the XWindow’s variables must be stored in a handle to a
  323.         record (of type ProgressWindoidInfoRecord whose fields are declared at 
  324.         the top) and then this handle is stored in the WRefCon of the window once 
  325.         it is created.  This way they can be accessed again when the window receives
  326.         messages. The handle is destroyed when the window gets its goodbye kiss. */
  327.  
  328.     BlockMove(textParam, (*progWindInfo)->windowText, *textParam+1);
  329.     (*progWindInfo)->windowFraction    = fractionParam;
  330.     (*progWindInfo)->progBarTop        = progBarTop;
  331.     (*progWindInfo)->progBarWidth    = progBarWidth;
  332.     
  333.     SetWRefCon(myWindowPtr, (long) progWindInfo);
  334.     
  335. } /* DoSetup */
  336.  
  337. void KillXWindow(XCmdPtr paramPtr, ProgressWindoidInfoHandle progWindInfo, WindowPtr theWindow)
  338. {
  339.     /* None of the fields in the XWindowInfoRec need to be destroyed,
  340.                 just the handle itself. */
  341.     DisposHandle((Handle) progWindInfo);
  342. }
  343.  
  344. void DrawProgText(XCmdPtr paramPtr, ProgressWindoidInfoHandle progWindInfo, WindowPtr theWindow)
  345. {
  346.     Rect        textRect;
  347.     FontInfo    fInfo;
  348.     short        windowWidth;
  349.     
  350.     GetFontInfo(&fInfo);
  351.     
  352.     windowWidth = theWindow->portRect.right - theWindow->portRect.left;
  353.     
  354.     SetRect(&textRect, kTextLeftSideSpace, kTextTopSpace, 
  355.                                 windowWidth, kTextTopSpace + fInfo.ascent + fInfo.descent);
  356.     EraseRect(&textRect);
  357.     
  358.     MoveTo(kTextLeftSideSpace, kTextTopSpace + fInfo.ascent);
  359.     DrawString((*progWindInfo)->windowText);
  360. }
  361.  
  362. void DrawProgBar(XCmdPtr paramPtr, ProgressWindoidInfoHandle progWindInfo, WindowPtr theWindow)
  363. {
  364.     Rect    progressBar;
  365.     Rect    completionBar;
  366.     Rect    unCompleteBar;
  367.     long    completionWidth;
  368.     Str255    tempStr;
  369.     
  370.     SetRect(&progressBar, kProgBarSideSpace, (*progWindInfo)->progBarTop, 
  371.                                     kProgBarSideSpace + (*progWindInfo)->progBarWidth, 
  372.                                     (*progWindInfo)->progBarTop + kProgBarHeight);
  373.  
  374.     completionWidth = FracMul(((*progWindInfo)->progBarWidth - 1), (*progWindInfo)->windowFraction);
  375.     SetRect(&completionBar, 
  376.                         progressBar.left + 1, 
  377.                         progressBar.top + 1, 
  378.                         progressBar.left + 1 + completionWidth, 
  379.                         progressBar.bottom - 1);
  380.                                     
  381.     SetRect(&unCompleteBar, completionBar.right, completionBar.top, 
  382.                                     kProgBarSideSpace + (*progWindInfo)->progBarWidth - 1, 
  383.                                     completionBar.bottom);
  384.                                     
  385.     PaintRect(&completionBar);
  386.     EraseRect(&unCompleteBar);
  387.     FrameRect(&progressBar);
  388. }
  389.             
  390. void DoUpdate(XCmdPtr paramPtr, ProgressWindoidInfoHandle progWindInfo, WindowPtr theWindow)
  391. {
  392.     BeginUpdate(theWindow);
  393.     
  394.         EraseRect(&theWindow->portRect);
  395.         DrawProgText(paramPtr, progWindInfo, theWindow);
  396.         DrawProgBar(paramPtr, progWindInfo, theWindow);
  397.                 
  398.     EndUpdate(theWindow);
  399. }
  400.  
  401. void DoMouseDown(XCmdPtr paramPtr, ProgressWindoidInfoHandle progWindInfo, 
  402.                     WindowPtr theWindow, EventRecord *theEvent)
  403. {
  404.  
  405.     switch (FindWindow(theEvent->where,&theWindow)) {
  406.         case inGoAway:
  407.             if (TrackGoAway(theWindow, theEvent->where))
  408.                 CloseXWindow(paramPtr, theWindow);
  409.             break;
  410.             
  411.         case inDrag:
  412.             paramPtr->passFlag = true;
  413.             break;
  414.             
  415.         /* case inContent: NOTHING    */
  416.     }
  417. }
  418.  
  419. Handle GetProperty(XCmdPtr paramPtr, ProgressWindoidInfoHandle progWindInfo, 
  420.                     WindowPtr theWindow, StringPtr propName)
  421. {
  422.     Str255        tempStr;
  423.  
  424.     if (StringEqual(paramPtr, propName, "\pProperties"))
  425.         {
  426.             return PasToZero(paramPtr, "\ptext,fraction,width,textFont,textSize");
  427.         }
  428.     
  429.     if (StringEqual(paramPtr, propName, "\pWidth"))
  430.         {
  431.             NumToStr(paramPtr, theWindow->portRect.right - theWindow->portRect.left, tempStr);
  432.             return PasToZero(paramPtr, tempStr);
  433.         }
  434.     
  435.     if (StringEqual(paramPtr, propName, "\pText"))
  436.         {
  437.             return PasToZero(paramPtr, (*progWindInfo)->windowText);
  438.         }
  439.     
  440.     if (StringEqual(paramPtr, propName, "\pFraction"))
  441.         {
  442.             ExtToStr(paramPtr, Frac2X((*progWindInfo)->windowFraction), tempStr);
  443.             return PasToZero(paramPtr, tempStr);
  444.         }
  445.     
  446.     if (StringEqual(paramPtr, propName, "\pTextFont"))
  447.         {
  448.             GetFontName(theWindow->txFont, tempStr);
  449.             return PasToZero(paramPtr, tempStr);
  450.         }
  451.     
  452.     if (StringEqual(paramPtr, propName, "\pTextSize"))
  453.         {
  454.             NumToStr(paramPtr, theWindow->txSize, tempStr);
  455.             return PasToZero(paramPtr, tempStr);
  456.         }
  457.     
  458.     /* This handles the properties: loc, visible (HyperCard supplies them) */
  459.     paramPtr->passFlag = true;
  460.     return nil;
  461. } /* GetProperty */
  462.  
  463. void SetProperty(XCmdPtr paramPtr, ProgressWindoidInfoHandle progWindInfo, 
  464.                     WindowPtr theWindow, StringPtr propName, Handle propVal)
  465. {
  466.     Str255        tempStr;
  467.     
  468.  
  469.     if (StringEqual(paramPtr, propName, "\pFraction"))
  470.         {
  471.             ZeroToPas(paramPtr,*propVal,tempStr);
  472.             
  473.             (*progWindInfo)->windowFraction = X2Frac(StrToExt(paramPtr, tempStr));
  474.  
  475.             LimitFractionValue(&((*progWindInfo)->windowFraction));
  476.             DrawProgBar(paramPtr, progWindInfo, theWindow);
  477.             return;
  478.         }
  479.         
  480.     if (StringEqual(paramPtr, propName, "\pText"))
  481.         {
  482.             ZeroToPas(paramPtr,*propVal,tempStr);
  483.             BlockMove(tempStr, (*progWindInfo)->windowText, *tempStr+1);
  484.             DrawProgText(paramPtr, progWindInfo, theWindow);
  485.             /* Sometimes the font misbehaves & draws in the progbar area */
  486.             DrawProgBar(paramPtr, progWindInfo, theWindow);
  487.             return;
  488.         }
  489.         
  490.     if (StringEqual(paramPtr, propName, "\pWidth"))
  491.         {
  492.             short    newWidth;
  493.             short    windowHeight;
  494.             short    progBarWidth;
  495.  
  496.             ZeroToPas(paramPtr,*propVal,tempStr);
  497.             newWidth = StrToNum(paramPtr, tempStr);
  498.             LimitWidthValue(&newWidth);
  499.             (*progWindInfo)->progBarWidth = newWidth - (2 * kProgBarSideSpace);
  500.             
  501.             windowHeight = theWindow->portRect.bottom - theWindow->portRect.top;
  502.             SizeWindow(theWindow, newWidth, windowHeight, true);
  503.             InvalRect(&theWindow->portRect);
  504.             
  505.             DrawProgText(paramPtr, progWindInfo, theWindow);    /* More or less text may fit now. */
  506.             DrawProgBar(paramPtr, progWindInfo, theWindow);    /* The progress bar will be longer or shorter now. */
  507.             return;
  508.         }
  509.         
  510.     if (StringEqual(paramPtr, propName, "\pTextFont"))
  511.         {
  512.             short    newFontNumber;
  513.             ZeroToPas(paramPtr,*propVal,tempStr);
  514.             GetFNum(tempStr, &newFontNumber);
  515.             theWindow->txFont = newFontNumber;    /* Same as QuickDraw SetFont */
  516.             
  517.             DrawProgText(paramPtr, progWindInfo, theWindow);
  518.             /* Sometimes the font misbehaves & draws in the progbar area */
  519.             DrawProgBar(paramPtr, progWindInfo, theWindow);
  520.             return;
  521.         }
  522.         
  523.     if (StringEqual(paramPtr, propName, "\pTextSize"))
  524.         {
  525.             short    newSize;
  526.             short    progBarTop;
  527.             short    newHeight;
  528.             short    windowWidth;
  529.             
  530.             ZeroToPas(paramPtr,*propVal,tempStr);
  531.             newSize = StrToNum(paramPtr, tempStr);
  532.             LimitTextSizeValue(&newSize);
  533.             theWindow->txSize = newSize;
  534.             
  535.             progBarTop = kTextTopSpace + newSize + kTextBottomSpace;
  536.             (*progWindInfo)->progBarTop = progBarTop;
  537.             
  538.             newHeight = progBarTop +  kProgBarHeight + kProgBarBottomSpace;
  539.             windowWidth = theWindow->portRect.right - theWindow->portRect.left;
  540.             SizeWindow(theWindow, windowWidth, newHeight, true);
  541.             InvalRect(&theWindow->portRect);
  542.             
  543.             DrawProgText(paramPtr, progWindInfo, theWindow);    /* More or less text may fit now. */
  544.             DrawProgBar(paramPtr, progWindInfo, theWindow);    /* The progress bar at a different height now. */
  545.             return;
  546.         }
  547.         
  548.     /* This handles the properties: loc, visible (HyperCard will set them) */
  549.     paramPtr->passFlag = true;
  550. } /* SetProperty */
  551.  
  552.     
  553. void ProcessEvent(XCmdPtr paramPtr, XWEventInfoPtr myXWEventInfoPtr, 
  554.                         WindowPtr myWindow, EventRecord *myEvent)
  555. {
  556.     ProgressWindoidInfoHandle progWindInfo = (ProgressWindoidInfoHandle) GetWRefCon(myWindow);
  557.     
  558.     switch (myEvent->what) {
  559.         case mouseDown:
  560.             DoMouseDown(paramPtr, progWindInfo, myWindow, myEvent);
  561.             break;
  562.         case updateEvt:
  563.             DoUpdate(paramPtr, progWindInfo, myWindow);
  564.             break;
  565.         case app4Evt:
  566.             ShowHide(myWindow, (myEvent->message % 2 != 0));
  567.             break;
  568.         case xCursorWithin:
  569.             paramPtr->passFlag = true;
  570.             break;
  571.         case xGetPropEvt:
  572.             myXWEventInfoPtr->eventResult = 
  573.                 GetProperty(paramPtr, progWindInfo, myWindow, (StringPtr) myXWEventInfoPtr->eventParams[0]);
  574.             break;
  575.         case xSetPropEvt:
  576.             SetProperty(paramPtr, progWindInfo, myWindow, (StringPtr) myXWEventInfoPtr->eventParams[0], (Handle) myXWEventInfoPtr->eventParams[1]);
  577.             break;
  578.         case xCloseEvt:
  579.             KillXWindow(paramPtr, progWindInfo, myWindow);
  580.             paramPtr->passFlag = true;
  581.             break;
  582.     }
  583.     
  584. }
  585.  
  586. void DoEvent(XCmdPtr paramPtr)
  587. {
  588.     GrafPtr            savePort;
  589.     EventRecord        myEvent;
  590.     WindowPtr        myWindow;
  591.     XWEventInfoPtr    myXWEventInfoPtr;
  592.     
  593.     myXWEventInfoPtr = (XWEventInfoPtr) (paramPtr->params[0]);
  594.     myWindow = myXWEventInfoPtr->eventWindow;
  595.     myEvent = myXWEventInfoPtr->event;
  596.  
  597.     GetPort(&savePort);
  598.     SetPort(myWindow);
  599.     ProcessEvent(paramPtr, myXWEventInfoPtr, myWindow, &myEvent);
  600.     SetPort(savePort);
  601. }
  602.